//===============================================================================
// Microsoft patterns & practices Enterprise Library Contribution
// Query Application Block
//===============================================================================

using System;
using System.ComponentModel;
using EntLibContrib.Query.Properties;

namespace EntLibContrib.Query.Configuration.Design
{
	/// <summary>
	/// Represents a localized <see cref="DescriptionAttribute"/>.
	/// </summary>
	[AttributeUsage(AttributeTargets.All)]
	public sealed class QueryDescriptionAttribute : DescriptionAttribute
	{
		#region Fields
		private bool replaced;
		#endregion

		#region Properties
		/// <summary>
		/// Gets the description stored in the attribute.
		/// </summary>
		/// <value>
		/// The description stored in the attribute.
		/// </value>
		public override string Description
		{
			get
			{
				if (!replaced)
				{
					replaced = true;
					base.DescriptionValue = InternalResources.ResourceManager.GetString(base.Description);
				}
				return base.Description;
			}
		}
		#endregion

		#region Construction
		/// <summary>
		/// Initialize a new instance of the <see cref="QueryDescriptionAttribute"/> class with the <see cref="Type"/> containing the resources and the resource name.
		/// </summary>
		/// <param name="description">The resources string name.</param>
		public QueryDescriptionAttribute (string description)
			: base(description)
		{
		}
		#endregion
	}
}